﻿using System;
using System.Collections.Generic;
using System.Linq;
using Repository.EF;
using Repository.Repositories.Interfaces;

namespace Repository.Repositories.EFRepository
{
    public class SkillPointsRepository : ISkillPointsRepository
    {
        private UseeInfoTBEntities ctx = new UseeInfoTBEntities();

        public List<SkillPoints> QueryAll()
        {
            return ctx.SkillPoints.ToList();
        }

        public List<SkillPoints> QueryAllMain()
        {
            return ctx.SkillPoints.Where(sp => sp.ParentId == null).ToList();
        }

        public SkillPoints FirstOrDefault(Func<SkillPoints, bool> exp)
        {
            return ctx.SkillPoints.FirstOrDefault(exp);
        }

        public void Persist(SkillPoints skillPoints)
        {
            ctx.SkillPoints.Add(skillPoints);
            ctx.SaveChanges();
        }
    }
}
